<?php
/*
 * This page is to show Reports.
 */
$rep = true;
include 'all.php';
?>

<?php include '../head.php'; ?>
<title>Reports</title>
<style>
    .bb th, .bb td{
        border-bottom:  1px #000000 dotted !important ;
    }
</style>
<body>
    <div id="wrapper">

        <?php include '../header_profile.php'; ?>
        <?php include '../menu_left.php'; ?>
        <div class="salus_bank_reg float_left">


            <a class="float_left" href="http://<?= $_SERVER['HTTP_HOST'] ?>/salusbaby/user" style="margin-left: 1%; margin-right: 1%;">
                <!--                    <div class="salus_bank_logo logo"></div>-->
                <img src="../../include/images/baby.png" width="104px;" height="50px;" />
                <div class="down_arrow"></div>
            </a>
            <?php
            $getme = mysql_query("select * from salus_buy_product where FK_fa_user_id='" . $_COOKIE['gid'] . "' and product_id ='1'  ") or die(mysql_error());
            if (mysql_num_rows($getme) != 0) {
                ?>
                <a class="float_left" href="http://<?= $_SERVER['HTTP_HOST'] ?>/salusme" style="margin-left: 1%; margin-right: 1%;" >
                    <img src="../../include/images/me.png" width="104px;" height="50px;" />
                </a>
            <?php }
            ?>

            <?php
            $getme = mysql_query("select * from salus_buy_product where FK_fa_user_id='" . $_COOKIE['gid'] . "' and product_id ='1'  ") or die(mysql_error());
            if (mysql_num_rows($getme) != 0) {
                ?>
                <a class="float_left" href="http://<?= $_SERVER['HTTP_HOST'] ?>/salusbaby" >
                    <img src="../../include/images/baby.png" width="104px;" height="50px;" />
                </a>
            <?php }
            ?>
            <div class="clear"></div>

            <div class="float_left top_menu "><a href="Records">DOCUMENTS</a></div>            




            <div class="clear"></div>

            <div class="float_right" style="width: 210px">

        <!--        <div class="float_right top_after_menu"><a href="http://www.ndroid360.com/salus/index.php/salus_bank/gen_pdf"><img id="send_mail" src="http://www.ndroid360.com/salus/public/frontend/images/icons/send.png" title="Send Email"/></a></div>-->


                <div class="float_right top_after_menu"><a href="?action=new"><img src="../../include/images/new.png" title="New"/></a></div>
            </div>

            <div class="clear"></div>
            <script>
                function vali_type()
                { 
                    var id_value = document.getElementById('vid').value;
 
                    if(id_value != '')
                    { 
                        var valid_extensions = /(.flv|.FLV)$/i;   
                        if(valid_extensions.test(id_value))
                        {                             
                        }
                        else
                        {
                            alert('Invalid Video File. You can only upload FLV video files.');
                        }
                    } 
                }

            </script>



            <div id="mainContent">
                <hr>
                <?php
                $action = $_GET['action'];
                if ($action == 'new') {

                    $avil = mysql_query("select * from baby_folders where bid='" . $_COOKIE['bid'] . "' and folder='Records' ") or die(mysql_error());
                    if (mysql_num_rows($avil) == 0) {
                        echo '<font color=red>Note : First create a new folder  <b><u>"Records"</u></b> to insert records and reports. </font>';
                    } else {
                        ?>
                        <form  method="post" action="../records/new_record.php" enctype="multipart/form-data" >
                            <table border="1" width="100%">
                                <tr>
                                    <td width="200px" >Report Type : </td>
                                    <td width="150px">
                                        <select name="type">
                                            <option value="Medical Report"> Medical Report </option>
                                            <option value="Orhtodontics"> Orthodontics </option>
                                            <option value="Clinical Folder"> Clinical Folder</option>
                                            <option value="X-ray"> X-ray</option>
                                            <option value="Test"> Test</option>
                                        </select>
                                    </td>
                                    <td width="250px"></td>
                                </tr>
                                <tr>
                                    <td>Description :</td>
                                    <td>
                                        <textarea name="desc" rows="4" cols="20" placeholder="Description" ></textarea> 
                                    </td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>Photo/ Image report :</td>
                                    <td><input type="file" name="img"   /></td>
                                    <td>(try to use JPG/PNG format)</td>
                                </tr>
                                <tr>
                                    <td>Video :</td>
                                    <td><input type="file" name="videofile" id="vid" onBlur="vali_type()" />  </td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>Attach Document :</td>
                                    <td><input type="file" name="docs"   /></td>
                                    <td>(you can include any files) zip format is recommended </td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td><input type="hidden" name="MAX_FILE_SIZE" value="100000000000" />
                                        <input type="submit" value="Create New Report" /></td>
                                    <td></td>
                                </tr>                        

                            </table>                    
                        </form>
                        <?php
                    }
                } elseif ($action == '') {
                    ?>
                    <table width="100%"  class="bb" style="text-align: center;">
                        <tr>
                            <th width="25">Sr.</th>
                            <th width="250">Report Type</th>
                            <th width="150">Image</th>
                            <th>Latest Update</th>                        
                            <th>Detail</th>
                        </tr>
                        <?php
                        $i = 1;
                        $q = mysql_query("select * from baby_user_reports where bid= '" . $_COOKIE['bid'] . "' ") or die(mysql_error());
                        while ($row = mysql_fetch_array($q)) {
                            ?>
                            <tr>
                                <td><?= $i ?></td>
                                <td><?= $row['type'] ?></td>
                                <td><a href="http://<?= $_SERVER['HTTP_HOST'] ?>/salusbaby/storage/<?= $_COOKIE['bid'] ?>/folders/Records/<?= $row['image'] ?>">click</a></td>
                                <td><?= $row['date'] ?></td>
                                <td><a href="?action=detail&sr=<?= $row['sr'] ?>">Detail</a></td>
                            </tr>
                        <?php } ?>
                    </table>                                 
                    <?php
                } elseif ($action == 'detail') {
                    $q = mysql_query("select * from baby_user_reports where bid ='" . $_COOKIE['bid'] . "' and sr='" . $_GET['sr'] . "' ") or die(mysql_error());
                    while ($row1 = mysql_fetch_array($q)) {
                        ?>

                        <table>
                            <tr>
                                <td>Report Type :</td>
                                <td><?= $row1['type'] ?></td>
                            </tr>
                            <tr>
                                <td>Description :</td>
                                <td><?= $row1['description'] ?></td>
                            </tr>
                            <tr>
                                <td>Last Updated Date :</td>
                                <td><?= $row1['date'] ?></td>
                            </tr>
                            <tr>
                                <td>Document :</td>
                                <td><?php
                if ($row1['document'] != '') {
                    echo '<a href=http://' . $_SERVER['HTTP_HOST'] . '/salusbaby/storage/' . $_COOKIE['bid'] . '/folders/Records/' . $row1['document'] . '>Download</a>';
                }
                        ?></td>
                            </tr>
                            <tr>
                                <td>Image :</td>
                                <td><?php
                            if ($row1['image'] != '') {
                                echo '<img src=http://' . $_SERVER['HTTP_HOST'] . '/salusbaby/storage/' . $_COOKIE['bid'] . '/folders/Records/' . $row1['image'] . ' />';
                            }
                        ?></td>
                            </tr>                    
                        </table>


                        <?php
                    }
                }
                ?>
            </div>

        </div><!-- wrapper over    -->
        <?php
        include '../../include/config.php';
        include '../menu_right.php';
        ?>
</body>
</html>